package com.game.league.task.dialog;

import android.annotation.SuppressLint;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.game.base.app.base.BaseDialogFragment;
import com.game.base.utils.DecimalUtil;
import com.game.league.R;
import com.game.league.databinding.DialogSignBinding;
import com.game.league.entrance.user.UserMgr;
import com.game.league.service.InterfaceMgr;

/**
 * 签到弹框
 * Created by Su on 2019/5/31.
 */
@SuppressLint("ValidFragment")
public class SignDialog extends BaseDialogFragment<DialogSignBinding> implements View.OnClickListener {

    public SignDialog() {
        settWindowAnimations(R.style.AnimScaleInScaleOutOverShoot);
        setGravity(Gravity.CENTER);
        setDialogSizeRatio(0, 0);
        setCanceledOnTouchOutside(false);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_sign;
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        initRewardedAdd();
        initView();
        initData();
        return getContentView();
    }

    @SuppressLint("SetTextI18n")
    private void initView() {
        binding.setClick(this);
        binding.tvSignCoin.setText("+ " + DecimalUtil.getFormatFloat(
                InterfaceMgr.getConfig().getSignReward()));
        binding.btnAd.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    }

    // 更新收支明细
    private void initData() {
        InterfaceMgr.getInstance().setFlowBillList(UserMgr.getCurrentUser(), "签到奖励",
                InterfaceMgr.getConfig().getSignReward(), true, null);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_submit:
                dismissAllowingStateLoss();
                break;
            case R.id.btn_ad:
                showRewardedAdd();
                break;
        }
    }

    private void initRewardedAdd() {
    }

    private void showRewardedAdd() {
    }
}
